package com.dailyblue.project.smbms.alibaba.role.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dailyblue.project.smbms.alibaba.commons.bean.Role;
import com.dailyblue.project.smbms.alibaba.commons.util.JsonResult;
import com.dailyblue.project.smbms.alibaba.commons.util.ResultTool;
import com.dailyblue.project.smbms.alibaba.role.mapper.RoleMapper;
import com.dailyblue.project.smbms.alibaba.role.service.RoleService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Cacheable(cacheNames = "findRoleById", key = "#id")
    public JsonResult findRoleById(int id) {
        QueryWrapper<Role> wrapper = new QueryWrapper<>();
        wrapper.eq("id", id);
        return ResultTool.success(this.getById(id));
    }
}
